//
//  SYTabbarItem.m


#import "SYTabbarItem.h"

@implementation SYTabbarItem

-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        // Item分割线
        UIImageView *splitLine = [[UIImageView  alloc] init];
        splitLine.frame = CGRectMake(0, 0, 60, 2);
        splitLine.image = [UIImage imageNamed:@"separator_tabbar_item.png"];
        [self addSubview:splitLine];
        
        self.backgroundColor = [UIColor whiteColor];
        
        self.icon = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
        [self addSubview:self.icon];
        
        
        self.title = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 40, 25)];
        self.title.font = [UIFont boldSystemFontOfSize:28];
        self.title.textColor = [UIColor grayColor];
        self.title.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.title];
        
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 6;
    }
    return self;
}

- (void)setTitleText:(NSString *)text
{
    self.title.text = text;
}

- (void)setIconFrameWithIsBigger:(BOOL)isBigger
{
    if (isBigger == YES) {
//        [self.icon mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(58*JCScreenWidth, 42*JCScreenHeight));
//        }];
    }else{
//        [self.icon mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(42*JCScreenWidth, 42*JCScreenHeight));
//        }];
        self.icon.bounds = CGRectMake(0, 0, 40, 40);
    }
}

- (void)setBackroundImg:(NSString *)backroundImg selectImg:(NSString *)selectImg
{
    self.selectedImage = selectImg;
    self.backgroundImage = backroundImg;
    [self.icon setImage:[UIImage imageNamed:backroundImg]];
}

//设置背景图片
- (void)setSelected
{
    self.title.textColor = [UIColor whiteColor];
    [self.icon setImage:[UIImage imageNamed:self.selectedImage]];
    self.backgroundColor = [UIColor yellowColor];
}

- (void)setUnSelected
{
    self.title.textColor = [UIColor grayColor];
    [self.icon setImage:[UIImage imageNamed:self.backgroundImage]];
    self.backgroundColor = [UIColor whiteColor];
}


//-(void)setFrame:(CGRect)frame{
//    //固定Item宽高
//    frame.size=CGSizeMake(60, 90);
//    [super setFrame:frame];
//}

@end
